/*
 * This file Copyright (c) 2015. Walle.
 * (http://www.wallellen.com). All rights reserved.
 *
 *
 * This file is dual-licensed under both the
 * Walle Agreement (WA) and the GNU General Public License.
 * You may elect to use one or the other of these licenses.
 *
 * This file is distributed in the hope that it will be
 * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
 * Redistribution, except as permitted by whichever of the GPL
 * or WA you select, is prohibited.
 *
 * 1. For the GPL license (GPL), you can redistribute and/or
 * modify this file under the terms of the GNU General
 * Public License, Version 3, as published by the Free Software
 * Foundation.  You should have received a copy of the GNU
 * General Public License, Version 3 along with this program;
 * if not, write to the Free Software Foundation, Inc., 51
 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * 2. For the Walle Agreement (WA), this file
 * and the accompanying materials are made available under the
 * terms of the WA which accompanies this distribution, and
 * is available at http://www.wallellen.com/agreement.html
 *
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 */

package com.wallellen.knowledge.doc.server;

import com.wallellen.authority.domain.User;
import com.wallellen.core.auth.domain.LoginUser;
import com.wallellen.core.sql.query.DataQuery;
import com.wallellen.core.sql.result.DataResult;
import com.wallellen.knowledge.doc.domain.DocRunInfo;
import com.wallellen.knowledge.doc.domain.ex.DocBrief;

import java.util.List;
import java.util.Map;


/**
 * 文档用量接口
 *
 * @author <a href="mailto:wallellen@hotmail.com">WALLE</a>
 * @version 20140902
 */
public interface DocRunInfoInter {
    /**
     * 用户访问知识
     *
     * @param docId
     */
    public void visitDoc(String docId, LoginUser user, String ip);

    /**
     * 关注一片文章
     */
    public void enjoyDoc(String userId, String docId);

    /**
     * 取消关注一片文章
     */
    public void unEnjoyDoc(String userId, String docId);

    /**
     * 用户是否关注一篇文章
     *
     * @return
     */
    public boolean isEnjoyDoc(String userId, String docId);

    /**
     * 获得文档的关注用户
     *
     * @param docid
     * @return
     */
    public List<String> getDocJoinUserIds(String docid);

    /**
     * 获得用户关注的文章
     *
     * @return
     */
    public DataQuery getUserEnjoyDoc(String userId);

    /**
     * 重新计算文章热度
     *
     * @param userId
     * @param docId
     */
    public void reCountDocHotNum(String docId);

    /**
     * 给文档一个好评（登录用户）必须配合loadRunInfo使用
     *
     * @param docId
     * @param user
     */
    public void praiseDoc(String docId, LoginUser user, String IP);

    /**
     * 给文档一个好评（未登录用户）必须配合loadRunInfo使用
     *
     * @param docId
     * @param IP
     */
    public void praiseDoc(String docId, String IP);

    /**
     * 给文档一个差评（登录用户）必须配合loadRunInfo使用
     *
     * @param docId
     * @param user
     */
    public void criticalDoc(String docId, LoginUser user, String IP);

    /**
     * 给文档一个差评（未登录用户）必须配合loadRunInfo使用
     *
     * @param docId
     * @param IP
     */
    public void criticalDoc(String docId, String IP);

    /**
     * 更新和加载计算用量信息
     *
     * @param docId
     * @return
     */
    public DocRunInfo loadRunInfo(String docId);

    /**
     * 获得最热知识
     *
     * @param num 返回多少条
     * @return
     */
    public List<DocBrief> getPubHotDoc(int num);

    /**
     * 展示最新知识
     */
    public List<DocBrief> getNewKnowList(int pagesize);

    /**
     * 获得分类知识
     *
     * @param typeid 分类id
     * @param userid 用户id
     * @param num    查询数量
     * @return
     */
    public List<DocBrief> getTypeDocs(String typeid, String userid, int num);

    /**
     * 获得置顶知识
     *
     * @param num
     * @return
     */
    public List<DocBrief> getPubTopDoc(int num);

    /**
     * 获得好评用户
     *
     * @param num
     * @return ID, NAME, SUMYES
     */
    public DataResult getStatGoodUsers(int num);

    /**
     * 获得好评小组
     *
     * @param num
     * @return
     */
    public DataResult getStatGoodGroups(int num);

    /**
     * 做多知识用户
     *
     * @param num
     * @return
     */
    public DataResult getStatMostUsers(int num);

    /**
     * 好评文档
     *
     * @param num
     * @return
     */
    public DataResult getStatGoodDocs(int num);

    /**
     * 差评文档
     *
     * @param num
     * @return
     */
    public DataResult getStatBadDocs(int num);

    /**
     * 整体用量
     *
     * @return
     * @throws Exception
     */
    public Map<String, Object> getStatNum() throws Exception;

    /**
     * 用户知识统计
     *
     * @param user
     * @return
     */
    public DataResult getStatUser(User user);

    /**
     * 获得用户所有文档
     *
     * @param userid
     * @param domtype
     * @param pagesize
     * @param pagenum
     * @return
     */
    public DataResult userDocs(String userid, String domtype, int pagesize, int pagenum);

    /**
     * 获得用户所有公开文档
     *
     * @param userid
     * @param domtype
     * @param pagesize
     * @param pagenum
     * @return
     */
    public DataResult userPubDocs(String userid, String domtype, int pagesize, int pagenum);

    /**
     * 获得我历史审核
     *
     * @param userid
     * @param pagesize
     * @param pagenum
     * @return
     */
    public DataResult getMyAuditedByUser(String userid, int pagesize, int pagenum);

    /**
     * 获得我的未审核文档
     *
     * @param userid
     * @param pagesize
     * @param pagenum
     * @return
     */
    public DataResult getMyAuditingByUser(String userid, int pagesize, int pagenum);

    /**
     * 获得需要我审核的文档列表
     *
     * @param user
     * @param pagesize
     * @param pagenum
     * @return
     */
    public DataResult getAuditDocByUser(String user, int pagesize, int pagenum);

    /**
     * 创建一个用户发布排名查询
     *
     * @param query
     * @return DataQuery
     */
    public DataQuery createReleaseRankingSimpleQuery(DataQuery query);
}
